const regBtn = document.querySelector('#btn-register') // 注册按钮
const usernameBox = document.querySelector('#input-email') // 账号输入框
const passwordBox = document.querySelector('#input-password') // 密码输入框
async function register(e) {
    try {
        e.preventDefault()
        if (isTrue(usernameBox.value, passwordBox.value)) {
            let res = await axios({
                url: "/register", method: "POST", data: {
                    username: usernameBox.value,
                    password: passwordBox.value
                }
            })
            if (usernameBox.value.length > 7 && passwordBox.value.length > 5) {
                pxmu.success(res.data.message);
            } else pxmu.fail(res.data.message)
        }
    }
    catch (error) {
        console.log(error);
        pxmu.fail(error.response.data.message);
    }
}
regBtn.addEventListener('click', register) 